app.controller('specificationController', function ($scope, $controller, specificationService) {
    $controller('baseController', {$scope: $scope});//继承
    $scope.searchEntity = {};

    $scope.findOne = function (id) {
        specificationService.findOne(id).success(function (response) {
            $scope.entity = response;
        });
    }
    $scope.search = function (page, rows) {
        specificationService.search(page, rows, $scope.searchEntity).success(function (response) {
            $scope.list = response.rows;
            $scope.paginationConf.totalItems = response.total;//更新总记录数
        })
    }
    $scope.deleteSpecification = function () {
        specificationService.deleteSpecification($scope.selectIds).success(function (response) {
            if (response.success) {
                $scope.reloadList();
                $scope.selectIds = [];
            } else {
                alert(response.message);
            }
        })
    }
    $scope.entity = {specificationOptionList: []};
    //新增选项行
    $scope.addTableRow = function () {
        $scope.entity.specificationOptionList.push({});
    }
    $scope.deleTableRow = function (index) {
        $scope.entity.specificationOptionList.splice(index, 1);
    }
    $scope.save = function () {
        specificationService.save($scope.entity).success(function (response) {
            if (response.success) {
                $scope.reloadList();
            } else {
                alert(response.message);
            }
        });
    }
});